using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Zsa.Emulation.Cartridge
{
    public class CartridgeFileInfoCollection : List<CartridgeFileInfo>
    {

        public CartridgeFileInfoCollection(int capacity)
            : base ( capacity )
        {
        }

        public CartridgeFileInfoCollection(IEnumerable<CartridgeFileInfo> collection)
            : base(collection)
        {
        }

        public CartridgeFileInfoCollection Filter(Mappers.MapperTypeNumber mapperNum)
        {
            return Filter(
                delegate(CartridgeFileInfo info)
                {
                    return info.MapperInformation.MapperTypeNumber == mapperNum;
                }
            );
        }

        public CartridgeFileInfoCollection Filter(Predicate<CartridgeFileInfo> fileInfo)
        {
            return new CartridgeFileInfoCollection(FindAll(fileInfo));
        }

        public void CopyRoms(string folder)
        {
            string _DestPath;
 
            for (int _TempIndex = 0; _TempIndex < Count; _TempIndex++)
            {
                _DestPath = folder + "\\" + this[_TempIndex].FileName;
                if (!File.Exists(_DestPath))
                {
                    File.Copy(this[_TempIndex].FullPath,_DestPath);
                }

            }
        }
    }
}
